package com.chao.sentinel.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author : Rookie
 * @description :
 * @date : 2022/5/28
 */
@Service
public class FlowServiceImpl implements FlowService{

    @Override
    @SentinelResource(value = "orderQuery",blockHandler = "handlerQuery")
    public String query(String p) {
        return "查询success" + p;
    }

    /**
     * 兜底方法
     * @param p
     * @param e
     * @return
     */
    public String handlerQuery(@RequestParam(required = false) String p, BlockException e){
        return "商品查询熔断！";
    }
}
